package cn.org.timespace.ons.socket.mina.filter;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

public class ESCardProtocolCodecFactory implements ProtocolCodecFactory {

	private ESCardProtocolEncoder encoder;
	
	private ESCardProtocolDecoder decoder;
	
	public ESCardProtocolCodecFactory() {
		this(Charset.defaultCharset());
	}

	public ESCardProtocolCodecFactory(Charset charset) {
		
		this.encoder = new ESCardProtocolEncoder(charset);
		
		this.decoder = new ESCardProtocolDecoder(charset);
		
	}
	@Override
	public ProtocolDecoder getDecoder(IoSession iosession) throws Exception {

		return this.decoder;
	}

	@Override
	public ProtocolEncoder getEncoder(IoSession iosession) throws Exception {
		
		return this.encoder;
	}

}
